package lianxi4;

import java.util.ArrayList;

public class StudentOpeator2 implements StudentOpeator {
    @Override
    public void printAllStudents(ArrayList<Student> students) {
        int num1 = 0;
        int num2 = 0;
        for (Student student : students) {
            if(student.getSex().equals("男")) num1++;
            if(student.getSex().equals("女")) num2++;
            System.out.println(student.toString());
        }
        System.out.println("男生人数："+num1);
        System.out.println("女生人数："+num2);
    }

    @Override
    public void printAllScores(ArrayList<Student> students) {
        double count = 0.0;
        double max = students.get(0).getScore();
        double min = students.get(0).getScore();
        for (Student student : students) {
            count += student.getScore();
            if(student.getScore() > max) max = student.getScore();
            if(student.getScore() < min) min = student.getScore();
        }
        count = count - max - min;
        System.out.println("学生平均成绩 ：" + count/(students.size()-2));
        System.out.println("最高分：" + max);

        System.out.println("最低分：" + min);
    }
}
